<template>
  <div class='rights_container'>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>

    <el-card>
      <el-table :data="rightsList" stripe border>
        <el-table-column type="index" label="#"></el-table-column>
        <el-table-column prop="authName" label="权限名称"></el-table-column>
        <el-table-column prop="path" label="路径"></el-table-column>
        <el-table-column label="权限等级">
          <template slot-scope="{ row }">
            <el-tag :type="level[row.level].type">{{ level[row.level].name }}</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import rights from '@/api/rights'

export default {
  name: 'MyRights',
  data () {
    return {
      rightsList: [],
      level: [
        { type: 'primary', name: '一级' },
        { type: 'success', name: '二级' },
        { type: 'warning', name: '三级' }
      ]
    }
  },
  components: {
  },
  methods: {
    // 1.获取权限列表
    async getRightsList () {
      const { data: res } = await rights.getRightsList('list')
      if (res.meta.status === 200) {
        this.rightsList = res.data
      } else {
        this.$message.error(res.meta.message)
      }
    }
  },
  created () {
    this.getRightsList()
  },
  mounted () {
  }
}
</script>

<style lang='less' scoped>
.el-breadcrumb {
  line-height: 50px;
}
</style>
